package com.lc.luzhengtang.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.activity.ConsumptionActiivty;
import com.lc.luzhengtang.bean.ShouquanBean;
import com.lc.luzhengtang.conn.Conn;
import com.lc.luzhengtang.imgloader.GlideCircleTransform;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

import static com.lc.luzhengtang.R.id.text_purchase;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class ProfitListAdapter extends BaseQuickAdapter<ShouquanBean.DataBeanX.DataBean, BaseViewHolder> {
    public ProfitListAdapter(List<ShouquanBean.DataBeanX.DataBean> data) {

        super(R.layout.item_profit, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, final ShouquanBean.DataBeanX.DataBean item) {
        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) helper.convertView);
        helper.setText(R.id.text_username, item.getName());
        helper.setText(R.id.text_purchase, item.getCommissionmoney()+"");
        helper.setText(R.id.text_shouyi,item.getTotalmoney()+"");
//        text_purchase
        helper.setText(R.id.text_purchase, item.getCommissionmoney()+"");
//        Glide.with(mContext).load("http://img4.imgtn.bdimg.com/it/u=3432487329,2901563519&fm=26&gp=0.jpg").transform(new GlideCircleTransform(mContext)).into((ImageView) helper.getView(R.id.img_circle));
        Glide.with(mContext).load(Conn.HOST3+item.getAvatar()).transform(new GlideCircleTransform(mContext)).error(R.mipmap.touxiang).into((ImageView) helper.getView(R.id.img_circle));
        helper.setTag(R.id.text_username,helper.getAdapterPosition());
        helper.setTag(text_purchase,helper.getAdapterPosition());
        helper.setTag(R.id.img_circle,helper.getAdapterPosition());


//        startActivity(new Intent(TeamActivityListActivity.this,ConsumptionActiivty.class));
        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //   WebActivity.runActivity(mContext, model.desc, model.url);
                Intent intent = new Intent();
                intent.putExtra("goodstype_id", item.getId() + "");
                intent.putExtra("type_name",item.getName());

                intent.setClass(mContext, ConsumptionActiivty.class);
                mContext.startActivity(intent);
            }
        });
    }


}
